<?php

class UserAddressTb extends \Phalcon\Mvc\Model
{

    /**
     *
     * @var integer
     */
    public $id;

    /**
     *
     * @var integer
     */
    public $user_id;

    /**
     *
     * @var string
     */
    public $type;

    /**
     *
     * @var string
     */
    public $address;

    /**
     *
     * @var string
     */
    public $long;

    /**
     *
     * @var string
     */
    public $lat;

    /**
     *
     * @var string
     */
    public $google_add;

    /**
     *
     * @var string
     */
    public $region;

    /**
     *
     * @var string
     */
    public $city;

    /**
     *
     * @var string
     */
    public $date_created;

    /**
     *
     * @var string
     */
    public $date_modified;

    /**
     * Independent Column Mapping.
     */
    public function columnMap()
    {
        return array(
            'id' => 'id', 
            'user_id' => 'user_id', 
            'type' => 'type', 
            'address' => 'address', 
            'long' => 'long', 
            'lat' => 'lat', 
            'google_add' => 'google_add', 
            'region' => 'region', 
            'city' => 'city', 
            'date_created' => 'date_created', 
            'date_modified' => 'date_modified'
        );
    }

    public function beforeValidationOnCreate()
    {
        $this->date_created = CURR_DATE;
    }

    public function beforeValidationOnUpdate()
    {
        $this->date_created = CURR_DATE;
    }

    public function listCities()
    {
        $phql = "SELECT DISTINCT city FROM UserAddressTb";
        $data = $this->modelsManager->executeQuery($phql);
        return $data;
    }
}
